/**
* inputTimeStatsChart functions
* copyright@Catosoft.com reserved, 2016
* 2016.07.30, created by Eric.Wang
*/



/*
* get data
*/
var getedcInputTimeStatsData = function(){
	var data = {

	};
	var option = {
		url: '/draft/data/inputtime/stat/v1',
		type: 'GET',
		data: data,
	};
	createAjax(option, function(err, res){
		if(!err){
			inputTimeStatsTable('inputTimeStatsTable', res);
		}
	});
}

var getInputTimeInfoData = function(){
	var data = {

	};
	var option = {
		url: '/draft/data/inputtime/info/v1',
		type: 'GET',
		data: data,
	};
	createAjax(option, function(err, res){
		if(!err){
			inputTimeInfoTable('inputTimeInfoTable', res);
		}
	});
}

/*
* draw charts
*/
var inputTimeStatsTable = function(element, data){
	$('#' + element).bootstrapTable({
		data: data.list,
		classes: 'table table-hover',
		pagination: false,
		pageSize: 20,
		pageNumber: 1,
		pageList: [20, 50],
		sidePagination: 'client',
		showRefresh: true,
		showColumns: true,
		buttonsAlign: 'right',
		showExport: true,
		exportDataType: 'all',
		exportTypes: ['csv', 'txt', 'excel'],
		locale: 'zh-CN',
		columns: [
		{
			field: 'Number',  
	    title: '序号',  
	    formatter: function (value, row, index) {  
	    	return index + 1;  
	    }
		},
		{
			title: '中心',
			field: 'pursuercodes',
		}, {
			title: '中位录入时间/d',
			field: 'middle_input_time',
		}, {
			title: '平均录入时间/d',
			field: 'eve_input_time',
		}],

	});
}

var inputTimeInfoTable = function(element, data){
	$('#' + element).bootstrapTable({
		data: data.list,
		classes: 'table table-hover',
		pagination: false,
		pageSize: 20,
		pageNumber: 1,
		pageList: [20, 50],
		sidePagination: 'client',
		showRefresh: true,
		showColumns: true,
		buttonsAlign: 'right',
		showExport: true,
		exportDataType: 'all',
		exportTypes: ['csv', 'txt', 'excel'],
		locale: 'zh-CN',
		columns: [
		{
			field: 'Number',  
	    title: '序号',  
	    formatter: function (value, row, index) {  
	    	return index + 1;  
	    }
		},
		{
			title: '中心',
			field: 'pursuercodes',
		}, {
			title: '随机号',
			field: 'random_number',
		}, {
			title: '随机化日期',
			field: 'random_date',
		}, {
			title: '录入日期',
			field: 'input_date',
		}, {
			title: '访视一访视日期',
			field: 'period_one_date',
		}, {
			title: '访视一录入日期',
			field: 'period_one_input_date',
		}, {
			title: '访视二访视日期',
			field: 'period_two_date',
		}, {
			title: '方式二录入日期',
			field: 'period_tow_input_date',
		}],

	});
}

$(function(){
	getedcInputTimeStatsData();
	getInputTimeInfoData();
});